//
//  Kingfisher+Extension.swift
//  SwiiftProject
//
//  Created by Apple on 2019/5/16.
//  Copyright © 2019 lazyloading. All rights reserved.
//

import Foundation
import UIKit
import Kingfisher


extension UIImageView{
    
    /// 加载网络图片
    ///
    /// - Parameters:
    ///   - url: url
    ///   - placeholder: 占位图
    func setImage(url : String! , placeholder : UIImage? = nil) -> Void {
        let path = URL.init(string: url);
        self.kf.setImage(with: path, placeholder:placeholder, options: [.transition(.fade(0.3))])
    }
}

extension UIButton{
    
    /// 加载网络图片
    ///
    /// - Parameters:
    ///   - url: url
    ///   - placeholder: 占位图
    func setImage(url : String! , placeholder : UIImage? = nil) -> Void {
        let path = URL.init(string: url);
        self.kf.setImage(with: path, for: .normal, placeholder: placeholder, options: [.transition(.fade(0.3))])
    }
}
